package com.sinosoft.oms.mapper;

import com.sinosoft.oms.entity.oms.Appnt;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author:Frankiegg
 * @date:2018/5/16
 * @project:bee
 * @Modified By:
 **/
@Mapper
@Repository
public interface AppntMapper {
    /**
     * 插入投保人
     * @param newappnt
     * @return boolean
     * @throws
     */
    @Insert("INSERT INTO oms_order_appnt \n" +
            "\tVALUES\n" +
            "\t(#{orderId}, #{appntId}, #{name}, #{sex}, #{birthday}, #{idType}, \n" +
            "\t#{idNo}, #{certiExpireDate}, #{isCertiLongEffect}, #{age}, \n" +
            "\t#{addressNo}, #{nativePlace}, #{nationality}, #{rgtAddress}, \n" +
            "\t#{marriageStatus}, #{healthStatus}, #{stature}, #{avoirdupois}, \n" +
            "\t#{degree}, #{workCompany}, #{joinCompanyDate}, #{startWorkDate}, \n" +
            "\t#{position}, #{salary}, #{occupationCode}, #{occupationType}, \n" +
            "\t#{isSmoke}, #{isSocialInsu}, #{createUser}, #{gmtCreate}, \n" +
            "\t#{modifiedUser}, #{gmtModified}, #{isDeleted}\n" +
            "\t);\n")
    boolean insertAppnt(Appnt newappnt);
    /**
     * 根据ID修改投保人
     * @param newappnt
     * @return boolean
     * @throws
     */
    @Update("\n" +
            "UPDATE oms_order_appnt \n" +
            "\tSET\n" +
            "\torder_id = #{orderId} , \n" +
            "\tappnt_id = #{appnt_id} , \n" +
            "\tname = #{name} , \n" +
            "\tsex = #{sex} , \n" +
            "\tbirthday = #{birthday} , \n" +
            "\tid_type = #{id_type} , \n" +
            "\tid_no = #{id_no} , \n" +
            "\tcerti_expire_date = #{certi_expire_date} , \n" +
            "\tis_certi_long_effect = #{is_certi_long_effect} , \n" +
            "\tage = #{age} , \n" +
            "\taddress_no = #{address_no} , \n" +
            "\tnative_place = #{native_place} , \n" +
            "\tnationality = #{nationality} , \n" +
            "\trgt_address = #{rgt_address} , \n" +
            "\tmarriage_status = #{marriage_status} , \n" +
            "\thealth_status = #{health_status} , \n" +
            "\tstature = #{stature} , \n" +
            "\tavoirdupois = #{avoirdupois} , \n" +
            "\tdegree = #{degree} , \n" +
            "\twork_company = #{work_company} , \n" +
            "\tjoin_company_date = #{join_company_date} , \n" +
            "\tstart_work_date = #{start_work_date} , \n" +
            "\tposition = #{position} , \n" +
            "\tsalary = #{salary} , \n" +
            "\toccupation_code = #{occupation_code} , \n" +
            "\toccupation_type = #{occupation_type} , \n" +
            "\tis_smoke = #{is_smoke} , \n" +
            "\tis_social_insu = #{is_social_insu} , \n" +
            "\tcreate_user = #{create_user} , \n" +
            "\tgmt_create = #{gmt_create} , \n" +
            "\tmodified_user = #{modified_user} , \n" +
            "\tgmt_modified = #{gmt_modified} , \n" +
            "\tis_deleted = #{is_deleted}\n" +
            "\t\n" +
            "\tWHERE\n" +
            "\torder_id = #{order_id} ;\n")
    boolean updateAppntById(Appnt newappnt);
    /**
     * 根据ID查找投保人
     * @param orderId
     * @return com.sinosoft.oms.entity.oms.Appnt
     * @throws
     */
    @Select("")
    Appnt findAppntById(String orderId);

    /**
     * 查询所有投保人
     * @param
     * @return java.util.List<com.sinosoft.oms.entity.oms.Appnt>
     * @throws
     */
    @Results(id = "appnt",value={
            @Result(property = "orderId",column = "order_id"),@Result(property = "appntId",column = "appnt_id"),
            @Result(property = "name",column = "name"),@Result(property = "sex",column = "sex"),
            @Result(property = "birthday",column = "birthday"),@Result(property = "idType",column = "id_type"),
            @Result(property = "idNo",column = "id_no"),@Result(property = "certiExpireDate",column = "certi_expire_date"),
            @Result(property = "isCertiLongEffect",column = "is_certi_long_effect"),@Result(property = "age",column = "age"),
            @Result(property = "addressNo",column = "address_no"),@Result(property = "nativePlace",column = "native_place"),
            @Result(property = "nationality",column = "nationality"),@Result(property = "rgtAddress",column = "rgt_address"),
            @Result(property = "marriageStatus",column = "marriage_status"),@Result(property = "healthStatus",column = "health_status"),
            @Result(property = "stature",column = "stature"),@Result(property = "avoirdupois",column = "avoirdupois"),
            @Result(property = "degree",column = "degree"),@Result(property = "workCompany",column = "work_company"),
            @Result(property = "joinCompanyDate",column = "join_company_date"),@Result(property = "startWorkDate",column = "start_work_date"),
            @Result(property = "position",column = "position"),@Result(property = "salary",column = "salary"),
            @Result(property = "occupationCode",column = "occupation_code"),@Result(property = "occupationType",column = "occupation_type"),
            @Result(property = "isSmoke",column = "is_smoke"),@Result(property = "isSocialInsu",column = "is_social_insu"),
            @Result(property = "createUser",column = "create_user"),@Result(property = "gmtCreate",column = "gmt_create"),
            @Result(property = "modifiedUser",column = "modified_user"),@Result(property = "gmtModified",column = "gmt_modified"),
            @Result(property = "isDeleted",column = "is_deleted")
    })
    @Select("\n" +
            "select \torder_id, \n" +
            "\tappnt_id, \n" +
            "\tname, \n" +
            "\tsex, \n" +
            "\tbirthday, \n" +
            "\tid_type, \n" +
            "\tid_no, \n" +
            "\tcerti_expire_date, \n" +
            "\tis_certi_long_effect, \n" +
            "\tage, \n" +
            "\taddress_no, \n" +
            "\tnative_place, \n" +
            "\tnationality, \n" +
            "\trgt_address, \n" +
            "\tmarriage_status, \n" +
            "\thealth_status, \n" +
            "\tstature, \n" +
            "\tavoirdupois, \n" +
            "\tdegree, \n" +
            "\twork_company, \n" +
            "\tjoin_company_date, \n" +
            "\tstart_work_date, \n" +
            "\tposition, \n" +
            "\tsalary, \n" +
            "\toccupation_code, \n" +
            "\toccupation_type, \n" +
            "\tis_smoke, \n" +
            "\tis_social_insu, \n" +
            "\tcreate_user, \n" +
            "\tgmt_create, \n" +
            "\tmodified_user, \n" +
            "\tgmt_modified, \n" +
            "\tis_deleted\n" +
            "\t \n" +
            "\tfrom \n" +
            "\toms_order_appnt")
    List<Appnt> findAllAppnt();
}
